package com.zhou.imserver;

import java.io.*;
import java.net.Socket;

/**
 * Created by zhou on 2016/3/12.
 */
public class ServerWriter extends Thread {
    public OutputStream mOutputSream;

    public ServerWriter(OutputStream mOutputSream) {
        this.mOutputSream = mOutputSream;
    }

    @Override
    public void run() {
        super.run();
        while (true) {
            try {
                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
                String str = bufferedReader.readLine();
                BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(mOutputSream));
                bufferedWriter.write(str);
                bufferedWriter.newLine();
                bufferedWriter.flush();
            } catch (IOException e) {
                e.printStackTrace();
                System.out.println("this Thread has Some Problem Writer");
                break;
            }
        }
    }
}
